<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/header', TEMPLATE_INCLUDEPATH)) : (include template('public/header', TEMPLATE_INCLUDEPATH));?>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/comhead', TEMPLATE_INCLUDEPATH)) : (include template('public/comhead', TEMPLATE_INCLUDEPATH));?>

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li  <?php  if($type=='all') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('car',array('type'=>all));?>">全部车辆    </a></li>
    <li   <?php  if($type=='wait') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('car',array('type'=>wait,'status'=>1));?>">待审核</a></li>
    <li   <?php  if($type=='ok') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('car',array('type'=>ok,'status'=>2));?>">已审核</a></li>
    <!-- <li   <?php  if($type=='no') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('car',array('type'=>no,'status'=>3));?>">已下架</a></li> -->

</ul>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="car" />
            <div class="input-group">
                <input type="text" name="keywords" class="form-control" placeholder="请输入车辆名称">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>"/>
        </div>
    </div><!-- /.col-lg-6 -->
</div>
<div class="main">
    <!--<div class="panel panel-default">-->
        <!--<div class="panel-body ygbtn">-->
            <!--<div class="btn ygshouqian2" id="allselect">批量删除</div>-->
            <!--<div class="btn ygyouhui2" id="allpass">批量通过</div>-->
            <!--<div class="btn storegrey2" id="allrefuse">批量拒绝</div>-->
        <!--</div>-->
    <!--</div>-->
    <div class="panel panel-default">
        <div class="panel-heading">
            车辆列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div style="font-size: 16px;">
                <label class="control-label">二手车开关：</label>
                <label class="radio-inline">
                    <input onchange="check(this)" type="radio" id="emailwy1" name="is_open_car" value="1" <?php  if($info['is_open_car']==1) { ?>checked<?php  } ?> />
                    <label for="emailwy1">开启</label>
                </label>
                <label class="radio-inline">
                    <input onchange="check(this)" type="radio" id="emailwy2" name="is_open_car" value="0" <?php  if($info['is_open_car']!=1) { ?>checked<?php  } ?> />
                    <label for="emailwy2">关闭</label>
                </label>
            </div>
            <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <!--<td class="store_td1 col-md-1" style="text-align: center;">-->
                            <!--<input type="checkbox" class="allcheck" />-->
                            <!--<span class="store_inp">全选</span>-->
                        <!--</td>-->
                        <td class="col-md-1">编号</td>
                        <td class="col-md-1">排序</td>
                        <td class="col-md-1">品牌</td>
                        <td class="col-md-1">城市</td>
                        <td class="col-md-1">车辆名称</td>
                        <td class="col-md-1">车牌号</td>
                        <td class="col-md-1">首付/月供/官方指导价</td>
                        <td class="col-md-1">颜色/变速箱/排量</td>
                        <td class="col-md-1">电话</td>
                        <td class="col-md-1">是否推荐</td>
                        <td class="col-md-1">状态</td>
                        <td class="col-md-2">操作</td>
                    </tr>
                    <?php  if(is_array($list)) { foreach($list as $key => $item) { ?>
                    <tr class="yg5_tr2">
                        <!--<td>-->
                            <!--<input type="checkbox" name="test" value="<?php  echo $item['id'];?>">-->
                        <!--</td>-->
                        <td><?php  echo $item['id'];?></td>
                        <td><?php  echo $item['sort'];?></td>
                        <td><?php  echo $item['carbrand'];?></td>
                        <td><?php  echo $item['carcity'];?></td>
                        <td><?php  echo $item['name'];?></td>
                        <td><?php  echo $item['carnum'];?></td>
                        <td>￥<?php  echo $item['money'];?><br>￥<?php  echo $item['monthmoney'];?><br>￥<?php  echo $item['guidemoney'];?>
                        </td>
                        <td><?php  echo $item['color'];?> / <?php  if($item['grarbox'] == 1) { ?>手动挡
                            <?php  } else if($item['grarbox'] == 2) { ?>自动挡<?php  } ?> / <?php  echo $item['displacement'];?></td>
                        <td><?php  echo $item['phone'];?></td>

                        <td><?php  if($item['rec'] == 1) { ?>已推荐
                            <?php  } else if($item['rec'] == 2) { ?>未推荐
                            <?php  } ?></td>
                        <?php  if($item['status']==1) { ?>
                        <td>
                            <span class="label storered">待审核</span>
                        </td >
                        <?php  } else if($item['status']==2) { ?>
                        <td >
                            <span class="label storeblue">已审核</span>
                        </td>
                        <?php  } ?>
                        <td>

                            <?php  if($item['rec']==1) { ?>
                            <a href="<?php  echo $this->createWebUrl('car',array('op'=>'rec1','id'=>$item['id']));?>"><button class="btn storeblue btn-xs">取消推荐</button></a>
                            <?php  } ?>
                            <?php  if($item['rec']==2) { ?>
                            <a href="<?php  echo $this->createWebUrl('car',array('op'=>'rec2','id'=>$item['id']));?>"><button class="btn storered btn-xs">推荐</button></a>
                            <?php  } ?>
                            <?php  if($item['status']==1) { ?>
                            <a href="<?php  echo $this->createWebUrl('car',array('op'=>'xj','id'=>$item['id']));?>"><button class="btn storegrey btn-xs">通过</button></a>
                            <?php  } ?>
                            <?php  if($item['status']==2) { ?>
                            <a href="<?php  echo $this->createWebUrl('car',array('op'=>'sj','id'=>$item['id']));?>"><button class="btn storegrey btn-xs">拒绝</button></a>
                            <?php  } ?>
                            <a href="<?php  echo $this->createWebUrl('carinfo',array('id'=>$item['id']));?>" class="storespan btn btn-xs">
                                <span class="fa fa-pencil"></span>
                                <span class="bianji">编辑
                                    <span class="arrowdown"></span>
                                </span>
                            </a>
                            <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal<?php  echo $item['id'];?>">
                                <span class="fa fa-trash-o"></span>
                                <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                            </a>

                            <!-- <a href="<?php  echo $this->createWebUrl('carinfo',array('id'=>$item['id']));?>"><button class="btn btn-success btn-xs">查看</button></a>
                           <button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#myModal<?php  echo $item['id'];?>">删</button> -->
                        </td>

                    </tr>
                    <div class="modal fade" id="myModal<?php  echo $item['id'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body" style="font-size: 20px">
                                    确定删除么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a href="<?php  echo $this->createWebUrl('car', array('op' => 'delete', 'id' => $item['id']))?>" type="button" class="btn btn-info" >确定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php  } } ?>
                    <?php  if(empty($list)) { ?>
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无车辆信息
                        </td>
                    </tr>
                    <?php  } ?>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="text-right we7-margin-top">
    <?php  echo $pager;?>
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-8").show();
        $("#yframe-8").addClass("wyactive");
        /*删除*/
        function del(id) {
            var ret = confirm("您确定删除吗？")
            if (ret==true){
                $.ajax({
                    type:"POST",
                    url:"<?php  echo $this->createWebUrl('car',array('op'=>delete))?>",
                    dataType:"JSON",
                    data:{id:id},
                    success:function(res){
                        console.log(res);
                        location.reload();
                    }
                })
            }
        }
        // ———————————————批量删除———————————————
        $("#allselect").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的商品!');
                return false;
            }else if(confirm("确认要删除此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });

                $.ajax({
                    type:"post",
                    url:"<?php  echo $_W['siteroot'];?>/app/index.php?i=<?php  echo $_W['uniacid'];?>&c=entry&do=Deletecar&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })

            }
        });

        // ———————————————批量通过———————————————
        $("#allpass").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要通过的商品!');
                return false;
            }else if(confirm("确认要通过此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"<?php  echo $_W['siteroot'];?>/app/index.php?i=<?php  echo $_W['uniacid'];?>&c=entry&do=Adoptcar&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        // ———————————————批量拒绝———————————————
        $("#allrefuse").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要拒绝的商品!');
                return false;
            }else if(confirm("确认要拒绝此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"<?php  echo $_W['siteroot'];?>/app/index.php?i=<?php  echo $_W['uniacid'];?>&c=entry&do=Rejectcar&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });
    })
    function check() {
            var is_open_car= $('input[name="is_open_car"]:checked').val();
            // console.log(is_open_car);
            $.ajax({
                type:"POST",
                url:"<?php  echo $this->createWebUrl('car',array('op'=>change))?>",
                dataType:"JSON",
                data:{is_open_car:is_open_car},
                success:function(res){
                    console.log(res);
                    location.reload();
                }
            })
        }
</script>